const fp = require('lodash/fp')
const { Maybe, Container } = require('./support')

let maybe = Maybe.of([5, 6, 1])
let ex1 = () => {
    return maybe.map(fp.map(fp.curry(fp.add(1))))
}
console.log(ex1())

// 02
let xs = Container.of(['do', 'ray', 'me', 'fa', 'so', 'la', 'xi', 'do'])
const ex2 = () => {
    return xs.map(fp.first)
}
console.log(ex2())

// 03
let safeProp = fp.curry((x, o) => {
    return Maybe.of(o[x])
})
let user = { id: 2, name: "Albert" }
let ex3 = () => {
    return safeProp('name')(user).map(fp.first)
}
console.log(ex3())

// 04 
let ex4 = (n) => {
    return Maybe.of(n).map(parseInt)._value
}
console.log(ex4(null))